#ifndef __DOUBLELINKLIST_H_
#define __DOUBLELINKLIST_H_
#include<stddef.h>
#include"DynamicArray.h"

class DoubleLinkList
{
public:
    using ElementType=void*;//改为void *
    DoubleLinkList();
    DoubleLinkList(const DoubleLinkList& list);
    DoubleLinkList& operator=(const DoubleLinkList &list);   
    ~DoubleLinkList();
    size_t Size(){return size;}
    void setfunc (void (*Free)(void*),bool(*Compare)(void*,void*), bool(*ComBig)(void*,void*),void(*Print)(void *))
    {
            this->Free=Free;
            this->Print=Print;
            this->Compare=Compare;
            this->ComBig=ComBig;
    }
    void InsertTail(const ElementType& element);
    void InsertHead(const ElementType &element);
    void InsertByIndex(size_t index,const ElementType& element);
    //删除 2
    void RemoveByindex(size_t index);
    void RemoveByelement(const ElementType&element);    
    //查找 2
    ElementType* FindByIndex(size_t index);
    DArray:: DynamicArray FindElement(const ElementType& element);
    //修改 2
    void UpdateByindex(size_t index,const ElementType &elelment);
    void UpdateByElement(const ElementType &oldvalue,const ElementType &newvalue);
    //排序 快速排序
    void Sort();

    void show();


private:

    struct Node
    {
        Node(const ElementType&value)
        {
            this->value=value;
            next=prev=nullptr;

        }
        ElementType value;
        Node *next;//后驱指针
        Node *prev;//前驱指针
    };
    void FastSort(Node *start,Node *end);
    Node *head;//头指针
    Node *tail;//尾指针
    size_t size;  
    void(*Free)(void *);//释放对象的函数指针
    bool(*Compare)(void*,void*);
    bool(*ComBig)(void*,void*);//比较大小指针
    void(*Print)(void *);  


};















#endif